package demo7;

import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class TestStuddent {
    public static void main(String[] args) {
        Scanner input=new Scanner(System.in);
        do {
            System.out.println("请选择您的操作：1.显示全部学员2.删除3.增加4.修改5.查询");
            try {
                int num=input.nextInt();
                switch (num){
                    case 1:
                        Set<Student>students1=StudentManager.findAll();
                        System.out.println("学号\t姓名\t年龄");
                        for (Student s:students1
                             ) {
                            System.out.println(s.toString());
                        }
                        break;
                    case 2:
                        System.out.println("请输入删除的学号");
                         int id=input.nextInt();
                        boolean results= demo7.StudentManager.deleteSong(id);
                        if (results){
                          System.out.println("删除成功");
                        }
                        else {

                            System.out.println("您输入姓名不存在");
                        }
                        break;
                    case 3:
                        System.out.println("请输入学号");
                         id=input.nextInt();
                        System.out.println("请输入姓名");
                        String name=input.next();
                        System.out.println("请输入年龄");
                        int age=input.nextInt();
                        demo7.Student student=new demo7.Student(id,name,age);
                        demo7.StudentManager.adds(student);
                            System.out.println("新增学员成功!");
                        break;
                    case 4:
                        System.out.println("请输入修改后学员姓名");
                        name=input.next();
                        System.out.println("请输入修改的学号");
                        id=input.nextInt();
                        System.out.println("请输入修改后年龄");
                        age=input.nextInt();

                        results= demo7.StudentManager.mod(id,name,age);
                        if(results) {
                            System.out.println("修改学员成功!");
                        }
                        else {
                            System.out.println("学员学号不存在，修改失败！");
                        }
                        break;
                    case 5:
                        System.out.println("请输入查找的学员姓名");
                        name=input.next();
                        System.out.println(demo7.StudentManager.inquire(name));
                        break;
                    default:
                        System.out.println("没有您要的选项");
                        break;
                }
            }catch (Exception ex){
                System.out.println("没有您要的选项");
                ex.printStackTrace();
                input=new Scanner(System.in);
            }
        }while (true);
    }
}
